<?php
require_once "db.php";

$account_name = db_escape($_POST['user_deact']);
$action = db_escape($_POST['actionGroup']);

$exist_name="SELECT username FROM accounts WHERE username='$account_name'";
$exist_name_query = db_query($exist_name);
if (mysqli_num_rows($exist_name_query)==0) {
	echo 'Username '.$account_name.' does not exist!';
}
else{
	if ($action=='activate') {
		$status = 0;
		$msg = 'activated';
	}
	elseif ($action=='deactivate') {
		$status = 1;
		$msg = 'deactivated';
	}
	$update_act_deact = "UPDATE accounts SET active_or_not = '$status' WHERE username='$account_name'";
	db_query($update_act_deact);
	echo 'Account with username '.$account_name.' has been '.$msg.' !';
}
